Ext.define('AM.view.FinaceView', {
		extend: 'Ext.grid.Panel',
		alias : 'widget.finaceView',
		store : 'FinaceStore',
		columnLines:true,
//		selModel : Ext.create('Ext.selection.CheckboxModel'), 
		selModel: {
	        injectCheckbox: 0,
	        mode: "SIMPLE"    //"SINGLE"/"SIMPLE"/"MULTI"
	      
   		 },
   		selType: "checkboxmodel",
    	dockedItems: [{
        xtype: 'pagingtoolbar',
        dock: 'bottom',
        store : 'FinaceStore',
        displayInfo: true 
    }],
		columns: [	
			        //{text: '序号', xtype: 'rownumberer',width:50,align:'center'},
		            {text: '序号',  xtype: 'rownumberer',width:50,align:'center',tdCls:'background-color: #8EE5EE;'},
			        { text: 'ID', dataIndex: 'id', width:0,align:'center'},
			        { text: '绩效类别', dataIndex: 'name', width:180,align:'center'},
			        { text: '奖金', dataIndex: 'finace', width:180,align:'center'},
			        { text: '日期', dataIndex: 'date', width:180,align:'center'}
			        
			     ],
			   tbar: [
					  { xtype : "numberfield",
						fieldLabel: '请输入院月总收入',
						labelWidth:120,
					    name: 'finace',
					    minValue:0,
					    id:'searchfinace'
					  },
					  { xtype : "datefield",
						fieldLabel: '日期',
						labelWidth:35,
					    name: 'searchdate',
						format:'Y-m',
						id:'fiancedate'
					  },
					  { xtype: 'button', text: '查询奖金',handler:searchFinace,icon : 'Ext/restful/images/find.png'
					  },
					  { xtype: 'button', text: '计算奖金',handler:countFinace,icon : 'Ext/restful/images/add.png'
					  }
					]
		
})
function countFinace() {
	     var grid=this.ownerCt.ownerCt;
	     var fiance= Ext.getCmp('searchfinace').getValue();
	     var date= Ext.getCmp('fiancedate').getValue();
	     var searchdate= Ext.util.Format.date(date, 'Y-m');
   		 Ext.Ajax.request({
					url : 'departmentFinaceAction_conutFinace',
					success : function() {
						grid.getStore().on('beforeload', function (store, options) {
				          var new_params = {searchdate:searchdate}
				                Ext.apply(store.proxy.extraParams, new_params);
				       });//此处为加载条件
						  grid.getStore().reload();
								},
					failure : function() {
						Ext.MessageBox.alert("提示", "计算奖金失败！");
					},
					params : {
							reward:fiance,
							searchdate:searchdate
					}
		});	
		
	}
function searchFinace() {
   		 var grid=this.ownerCt.ownerCt;
   		 var date= Ext.getCmp('fiancedate').getValue();
	     var searchdate= Ext.util.Format.date(date, 'Y-m');
		 grid.getStore().on('beforeload', function (store, options) {
	          var new_params = {searchdate:searchdate}
	                Ext.apply(store.proxy.extraParams, new_params);
	       });//此处为加载条件
			  grid.getStore().reload();
					
		
	}